package Dao;

import DataClass.FullTimeTeacher;
import Util.JBDCUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class FullTimeTeacherDao {

    private static PreparedStatement preparedStatement = null;
    public static List<FullTimeTeacher> getFullTimeTeacher() throws SQLException {
        List<FullTimeTeacher> list = new ArrayList<FullTimeTeacher>();

        ResultSet data = FullTimeTeacherDao.getDataFullTimeTeacher();

        while(data.next()){
            String TCName = data.getString("TCName");
            String JTNo = data.getString("JTNo");
            String TQualification = data.getString("TQualification");
            String TDuties = data.getString("TDuties");
            String TProfessionalAffiliations = data.getString("TProfessionalAffiliations");
            String TAdminPositionsCollege = data.getString("TAdminPositionsCollege");
            list.add(new FullTimeTeacher(TCName,JTNo,TQualification,TDuties,TProfessionalAffiliations,TAdminPositionsCollege));
        }
        return list;
    }

    public static ResultSet getDataFullTimeTeacher() throws SQLException {

        if(preparedStatement == null){
            String sql = "select * from Teacher where TTno = '校内事业编全职教师'";
            preparedStatement = JBDCUtil.getPreparedStatement(sql);
        }

        ResultSet data = preparedStatement.executeQuery();
        JBDCUtil.commit();
        return data;
    }
}
